﻿@model IEnumerable<Common.Views.CartView>

@{
    ViewBag.Title = "Electros Ltd | Your cart";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Shopping Cart</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
    <div style="color:Red">
        @ViewBag.Message
    </div>
    
    if (Model != null)
    {
        if (Model.Count() > 0)
        {
        <table>
            <tr>
                <th>Product Name</th>
                <th>Image</th>
                <th>Quantity</th>
                <th>Price</th>
            </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ProductName)
                </td>
                <td>
                    <img height="150px" width="150px" src= "@Url.Content(item.ProductImage)" alt="@Html.DisplayFor(modelItem => item.ProductImage)" />
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ProductQuantity)
                </td>
                <td>
                    €@(item.ProductQuantity * item.ProductPrice)
                </td>
            </tr>
        }
        <tr>
                <td></td>
                <td></td>
                <td>Total Price:</td>
                <td><b>€@ViewBag.TotalPrice</b></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td><input type="submit" name="ViewCart" value="Checkout" /></td>
            </tr>
        </table>
        }
        else
        {
        <div style="color: Red"><b>Your shopping cart is empty!</b></div>
        }
    }
}